package com.hospital.rank.module.schedule;

import com.hospital.rank.module.base.PeriodType;
import com.hospital.rank.module.base.TargetType;
import com.hospital.rank.module.service.TRankService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MonthlyStat {
    @Autowired
    private TRankService rankService;
    @XxlJob("monthlyStat")
    public void monthlyStat() {
        long startTime = System.currentTimeMillis();
        XxlJobHelper.log("开始执行月度统计任务");
        TargetType[] targetTypes = TargetType.values();
        for (TargetType targetType : targetTypes) {
            rankService.rankStat(PeriodType.MONTHLY, targetType);
            rankService.rankStatInSection(PeriodType.MONTHLY, targetType);
        }
        XxlJobHelper.log("结束执行月度统计任务，耗时{}ms", System.currentTimeMillis() - startTime);
    }
}
